package com.xll.controller;

import com.alibaba.fastjson.JSONObject;
import com.xll.entity.Hotel;
import com.xll.service.HotelService;
import com.xll.utils.QueryInfo;
import com.xll.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/hotel")
public class HotelController {
    @Autowired
    private HotelService hotelService;

    @PostMapping("/findPage")
    public Result findAllCell(@RequestBody QueryInfo queryInfo) {
        return hotelService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加酒店信息")
    @PostMapping("/insert")
    public Result insertCell(@RequestBody Hotel hotel) {
        return hotelService.insert(hotel);
    }

    @ApiOperation(value = "修改酒店信息")
    @PostMapping("/update")
    public Result updateCell(@RequestBody Hotel hotel) {
        return hotelService.update(hotel);
    }

    @ApiOperation(value = "删除酒店信息")
    @DeleteMapping("/delete/{id}")
    public Result deleteCell(@PathVariable Long id) {
        return hotelService.delete(id);
    }

    @PostMapping("/mini/findAll")
    public Result findMenus(@RequestBody JSONObject jsonObject) {
        return hotelService.findAllByType(jsonObject);
    }

    @GetMapping("/detail/{id}")
    public  Result  foodDetail(@PathVariable Long id){
        return  hotelService.findById(id);
    }

}
